<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class FindhouseRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'area'   => 'required|string',
            'apartment' => 'required|string',
            'price' => 'required|numeric',
            'tel' => 'regex:/^1[3456789][0-9]{9}$/'
        ];
    }

    public function messages()
    {
        return [
            'area.required' => '请填写意向区域',
            'area.string' => '意向区域格式错误',
            'apartment.required' => '请填写意向户型',
            'apartment.string' => '意向户型格式错误',
            'price.required' => '请填写预算',
            'price.numeric' => '预算请填写数字',
            'tel.regex' => '手机号格式错误',
        ];
    }
}
